package com.ruoyi.develop.process.processPayApply.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;

import com.ruoyi.develop.process.processPleaseBuy.domain.ProcessPleaseBuy;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.process.processPayApply.mapper.ProcessPayApplyMapper;
import com.ruoyi.develop.process.processPayApply.domain.ProcessPayApply;
import com.ruoyi.develop.process.processPayApply.service.IProcessPayApplyService;

/**
 * 付款申请单操作记录Service业务层处理
 *
 * @author lmm
 * @date 2025-07-14
 */
@Service
public class ProcessPayApplyServiceImpl implements IProcessPayApplyService {
    @Resource
    private ProcessPayApplyMapper processPayApplyMapper;

    /**
     * 查询付款申请单操作记录
     *
     * @param id 付款申请单操作记录主键
     * @return 付款申请单操作记录
     */
    @Override
    public ProcessPayApply selectById(String id) {
        return processPayApplyMapper.selectById(id);
    }

    /**
     * 查询付款申请单操作记录列表
     *
     * @param entity 付款申请单操作记录
     * @return 付款申请单操作记录
     */
    @Override
    public List<ProcessPayApply> selectList(ProcessPayApply entity) {
        return processPayApplyMapper.selectList(entity);
    }

    /**
     * 新增付款申请单操作记录
     *
     * @param entity 付款申请单操作记录
     * @return 结果
     */
    @Override
    public int insert(ProcessPayApply entity) {
        if (StringUtils.isBlank(entity.getId())) {
            entity.setId(IdUtils.fastSimpleUUID());
        }
        entity.setCreateBy(SecurityUtils.getUsername());
        entity.setCreateTime(DateUtils.getNowDate());
        return processPayApplyMapper.insert(entity);
    }

    /**
     * 修改付款申请单操作记录
     *
     * @param entity 付款申请单操作记录
     * @return 结果
     */
    @Override
    public int update(ProcessPayApply entity) {
        entity.setUpdateBy(SecurityUtils.getUsername());
        entity.setUpdateTime(DateUtils.getNowDate());
        return processPayApplyMapper.update(entity);
    }

    /**
     * 批量删除付款申请单操作记录
     *
     * @param ids 需要删除的付款申请单操作记录主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return processPayApplyMapper.deleteByIds(ids);
    }

    /**
     * 删除付款申请单操作记录信息
     *
     * @param id 付款申请单操作记录主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return processPayApplyMapper.deleteById(id);
    }

    @Override
    public void insertProcess(String id, String type, String desc) {
        ProcessPayApply processPayApply = new ProcessPayApply();
        processPayApply.setId(IdUtils.fastSimpleUUID());
        processPayApply.setPayApplyId(id);
        processPayApply.setType(type);
        processPayApply.setOperDesc(desc);
        processPayApply.setOperTime(new Date());
        processPayApply.setOperBy(SecurityUtils.getUsername());
        processPayApplyMapper.insert(processPayApply);
    }

}
